package com.qing.picture.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

@Getter
public enum SpaceLevelEnum {

        COMMON("普通版", 0, 100L, 100L * 1024 * 1024),
        PROFESSIONAL("专业版", 1, 1000L, 1000L * 1024 * 1024),
        FLAGSHIP("旗舰版", 2, 10000L, 10000L * 1024 * 1024);

    /**
     * 空间等级枚举
     */
    private final String text;
    /**
     * 空间等级值
     */
    private final Integer value;
    /**
     * 空间图片的最大总大小
     */
    private final Long maxSize;
    /**
     * 空间图片的最大数量
     */
    private final Long maxCount;

    SpaceLevelEnum(String text, Integer value, Long maxSize, Long maxCount) {
        this.text = text;
        this.value = value;
        this.maxSize = maxSize;
        this.maxCount = maxCount;
    }

    /**
     * 根据 value 获取枚举
     */
    public static SpaceLevelEnum getEnumByValue(Integer value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        for (SpaceLevelEnum spaceLevelEnum : SpaceLevelEnum.values()) {
            if (spaceLevelEnum.value == value) {
                return spaceLevelEnum;
            }
        }
        return null;
    }
}
